1 package junit.quilt.cover.generic;
2
3 import java.util.Set;
4 import java.util.Map;
5 import java.util.HashSet;
6 import java.util.HashMap;
7
8 import org.apache.commons.graph.*;
9 import org.apache.commons.graph.algorithm.search.*;
10
11 import org.apache.bcel.classfile.*;
12 import org.apache.bcel.generic.*;
13
14
15 public class JSRInliner
16 implements org.apache.commons.graph.algorithm.search.Visitor
17 {
18 private ControlFlowGraph graph = null;
19 private Map vertices = new HashMap(); // Old Vertex X New Vertex
20
21 private BlockVertex retTarget = null; // Where should all RETs point too?
22 private BlockVertex root = null; // This is the root of the copy.
23
24 private EdgeFactory factory = null;
25
26 public JSRInliner( EdgeFactory factory,
27 BlockVertex retTarget ) {
28 this.retTarget = retTarget;
29 this.factory = factory;
30 }
31
32 public BlockVertex getRoot() {
33 return root;
34 }
35
36 public void discoverGraph( Graph g ) {
37 this.graph = (ControlFlowGraph) g;
38 }
39
40 public void discoverVertex( Vertex v ) {
41 BlockVertex copy = ((BlockVertex) v).copy();
42
43 graph.addVertex( copy );
44 vertices.put( v, copy );
45 if (root == null) {
46 root = copy;
47 }
48 }
49
50 public void discoverEdge( Edge e ) {
51 }
52
53 public void finishEdge( Edge e ) {
54 BlockVertex newSource =
55 (BlockVertex) vertices.get( graph.getSource( e ));
56 BlockVertex newTarget =
57 (BlockVertex) vertices.get( graph.getTarget( e ));
58
59 graph.addEdge( ((FlowControlEdge) e).copy( newSource, newTarget ),
60 newSource,
61 newTarget);
62 }
63
64 public void finishVertex( Vertex v ) {
65 BlockVertex block = (BlockVertex) vertices.get( v );
66
67 if (block.getLastInst().getInstruction() instanceof RET) {
68 graph.addEdge( factory.makeNormalEdge( block, retTarget ),
69 block, retTarget );
70 block.chomp();
71 }
72 }
73
74 public void finishGraph( Graph g ) {
75 }
76 }
This page was automatically generated by Maven